﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlTypes;

namespace HRM.BusinessLogic
{
    public class LabourContract_Info : Standard_Info
    {

        public LabourContract_Info()
        {
        }


        private int _LC_ID;

        public int LC_ID
        {
            get { return _LC_ID; }
            set { _LC_ID = value; }
        }

        private int _LC_ContractTypeID;

        public int LC_ContractTypeID
        {
            get { return _LC_ContractTypeID; }
            set { _LC_ContractTypeID = value; }
        }

        private int _LC_EmployeeID;

        public int LC_EmployeeID
        {
            get { return _LC_EmployeeID; }
            set { _LC_EmployeeID = value; }
        }

        private string _LC_No;

        public string LC_No
        {
            get { return _LC_No; }
            set { _LC_No = value; }
        }

        private string _LC_Description;

        public string LC_Description
        {
            get { return _LC_Description; }
            set { _LC_Description = value; }
        }

        private bool _LC_IsActive;

        public bool LC_IsActive
        {
            get { return _LC_IsActive; }
            set { _LC_IsActive = value; }
        }

        private DateTime _LC_Date;

        public DateTime LC_Date
        {
            get { return _LC_Date; }
            set { _LC_Date = value; }
        }
        private DateTime _LC_BeginDate;

        public DateTime LC_BeginDate
        {
            get { return _LC_BeginDate; }
            set { _LC_BeginDate = value; }
        }

        private DateTime _LC_FinishDate;

        public DateTime LC_FinishDate
        {
            get { return _LC_FinishDate; }
            set { _LC_FinishDate = value; }
        }

        private DateTime _LC_BeginProbationPeriod;

        public DateTime LC_BeginProbationPeriod
        {
            get { return _LC_BeginProbationPeriod; }
            set { _LC_BeginProbationPeriod = value; }
        }

        private DateTime _LC_EndProbationPeriod;

        public DateTime LC_EndProbationPeriod
        {
            get { return _LC_EndProbationPeriod; }
            set { _LC_EndProbationPeriod = value; }
        }

        private string _LC_PlaceOfWork;

        public string LC_PlaceOfWork
        {
            get { return _LC_PlaceOfWork; }
            set { _LC_PlaceOfWork = value; }
        }

        private int _LC_PositionID;

        public int LC_PositionID
        {
            get { return _LC_PositionID; }
            set { _LC_PositionID = value; }
        }
        private int _LC_DepartmentID;

        public int LC_DepartmentID
        {
            get { return _LC_DepartmentID; }
            set { _LC_DepartmentID = value; }
        }
        private decimal _LC_Salary;

        public decimal LC_Salary
        {
            get { return _LC_Salary; }
            set { _LC_Salary = value; }
        }
    }

    public class LabourContract_Controller : Standard_Controller
    {
        #region "Contructor"
        private static LabourContract_Controller _instance;
        protected LabourContract_Controller() { }
        protected void Dispose()
        {
            _instance = null;
        }
        private static object _syncLock = new object();
        public static LabourContract_Controller Instance()
        {
            if (_instance == null)
            {
                lock (_syncLock)
                {
                    if (_instance == null)
                        _instance = new LabourContract_Controller();
                }
            }
            return _instance;
        }
        public static LabourContract_Controller Instance(String transName)
        {
            if (!String.IsNullOrEmpty(transName))
            {
                LabourContract_Controller _instanceTrans = new LabourContract_Controller();
                _instanceTrans.Trans_Name = transName;
                return _instanceTrans;
            }
            else
                return Instance();
        }
        #endregion
        public const String cs_Table_Name = "";

        public LabourContract_Info LabourContract_GetInfo(int Employee_ID)
        {
            return CBO.FillObject<LabourContract_Info>(DataConnect.ExecuteRow(DataConnect.WorkingConnect, Procedure_Name(cs_Table_Name, "HRM_LabourContract_GetInfoByEmployee", false), Employee_ID));
        }

        public int LabourContract_InsertNS(LabourContract_Info eInfo)
        {
            return Globals.Object_GetValue<int>(DataConnect.ExecuteScalar(DataConnect.WorkingConnect, Procedure_Name(cs_Table_Name, "HRM_LabourContract_InsertNS"),
                eInfo.LC_EmployeeID,
                eInfo.LC_No,
                eInfo.LC_Date == DateTime.MinValue ? (DateTime?) null : eInfo.LC_Date,
                eInfo.LC_BeginDate == DateTime.MinValue ? (DateTime?) null : eInfo.LC_BeginDate,
                eInfo.LC_ContractTypeID,
                eInfo.LC_PositionID,
                eInfo.LC_DepartmentID));
        }

        public bool LabourContract_UpdateNS(LabourContract_Info eInfo)
        {
            return Globals.Object_GetValue<bool>(DataConnect.ExecuteNonQuery(DataConnect.WorkingConnect, Procedure_Name(cs_Table_Name, "HRM_LabourContract_UpdateNS"),
                eInfo.LC_ID,
                eInfo.LC_EmployeeID,
                eInfo.LC_No,
                eInfo.LC_Date,
                eInfo.LC_BeginDate,
                eInfo.LC_ContractTypeID,
                eInfo.LC_PositionID,
                eInfo.LC_DepartmentID) > 0);
        }
    }
}
